
<template>
  <div>
    <HeaderTitle :nologin="nologin" :secondPage="secondPage"></HeaderTitle>
    <logoComponent :secondPage="secondPage"></logoComponent>
    <navComponent v-if="!secondPage"></navComponent>
    <breadcrumbs v-if="this.$route.path != '/' || this.$route.path != '/score' || this.$route.path != '/scoretest'"></breadcrumbs>
    <keep-alive>
      <nuxt-child/>
    </keep-alive>
    <footerComponent></footerComponent>
    <loginRegistered :isclose="isclose" :nologin="nologin" @closedialog="closedialog"></loginRegistered>
    <renzheng :isclose="isrenzheng" :nologin="nologin" @closerenzheng="closerenzheng"></renzheng>
  </div>
</template>
<script>



import HeaderTitle from "../components/HeaderTitle";
import logoComponent from "../components/logoComponent";
import navComponent from "../components/navComponent";
import loginRegistered from "../components/loginRegistered";
import renzheng from "../components/renzheng";

import footerComponent from "../components/footerComponent";
import breadcrumbs from "../components/breadcrumbs";

import { mapState } from "vuex";
import api from '../static/js/api.js';
var j,s;

var timeoutcon;
var closenum = 0;

var timeoutconrenzheng;
var closenumrenzheng = 0;

export default {
  transition: "test",
  scrollToTop: true,
  components: {
    HeaderTitle,
    logoComponent,
    navComponent,
    loginRegistered,
    footerComponent,
    breadcrumbs,
    renzheng
  },
  data(){
    return{
       routerName: [{name:'首页',path:'/'}],
       isclose:false,
       isrenzheng:true       
    }
  },
  methods:{
    getUserInfo(){
      if(this.$store.state.nologin){
            this.$store.state.showlogin = true;
            this.$store.state.userinfo = {};
        }  
    },
    openrenzheng(){
       if(this.$store.state.nologin){
            this.$store.state.showrenzheng = true;
            this.$store.state.userinfo = {};
        }  
    },
    closerenzheng(){
       closenumrenzheng ++;
      clearTimeout(timeoutconrenzheng)
      this.$store.state.showrenzheng = false;
     
      timeoutconrenzheng = setTimeout(this.openrenzheng, 15000);
      this.isrenzheng = false
    },
    closedialog(){
      closenum ++;
      clearTimeout(timeoutcon)
      this.$store.state.showlogin = false;

      if(closenum == 1){
       timeoutcon = setTimeout(this.getUserInfo, 10000);
      }else if(closenum > 1){
       timeoutcon = setTimeout(this.getUserInfo, 5000);
      }
    }
  },
  computed: {
    ...mapState(["nologin", "secondPage"])
  },
  watch: {
    '$route': function(to, from) {
      clearTimeout(timeoutcon)
      clearTimeout(timeoutconrenzheng)

       var path = this.$route.path;

       if(path == "/equity" || path == "/trust" || path == "/fund" || path.indexOf("product") != -1 || path.indexOf("add5") != -1 ){
         this.getUserInfo()
       }else if(path == "/research" || path == "/advisory" || path.indexOf("newslist") != -1 || path.indexOf("column") != -1 || path.indexOf("post") != -1){
           timeoutconrenzheng = setTimeout(this.openrenzheng, 30000);
       }
    }
  },
  mounted: function() {
    clearTimeout(timeoutcon)
    clearTimeout(timeoutconrenzheng)
    
    var href = window.location.href;
    if (localStorage.nologin == "false") {
            this.$store.state.nologin = false;
            this.$store.state.showlogin = false;
            this.$store.state.userinfo = JSON.parse(localStorage.userinfo);
    }else{
        if(href.indexOf("research") != -1 || href.indexOf("advisory") != -1 || href.indexOf("web") != -1 || href.indexOf("school") != -1 
           || href.indexOf("post") != -1  || href.indexOf("newslist") != -1 || href.indexOf("column") != -1 ){    //新闻
           timeoutconrenzheng = setTimeout(this.openrenzheng, 30000);
              //|| href.indexOf("product") != -1
        }else if(href.indexOf("equity") != -1 || href.indexOf("trust") != -1 || href.indexOf("fund") != -1 || href.indexOf("product") != -1 || href.indexOf("add5") != -1 ){ //产品  || href.indexOf("insurance") != -1 || href.indexOf("house") != -1
              this.getUserInfo()
        }
    }

    
          window['_MEIQIA'] = window['_MEIQIA'] || function () {
              (window['_MEIQIA'].a = window['_MEIQIA'].a || []).push(arguments)
          };
          j = document.createElement('script'),
          s = document.getElementsByTagName('script')[0];
          j.async = true;
          j.charset = 'UTF-8';
          j.src = 'https://static.meiqia.com/dist/meiqia.js?_=t';
          s.parentNode.insertBefore(j, s);
      
          _MEIQIA('entId', 103141);
          _MEIQIA('withoutBtn');
          _MEIQIA('allSet', function () {
              var __outerBtn = document.getElementById('xxx');
              __outerBtn.onclick = function () {
                   _MEIQIA('showPanel');
              };
              _MEIQIA('showPanel');
          });
  }
};
</script>

